//
//  fenLeiTableViewCell.m
//  spotrs
//
//  Created by xu on 16/5/11.
//  Copyright © 2016年 TZ. All rights reserved.
//

#import "fenLeiTableViewCell.h"

@implementation fenLeiTableViewCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _dataArray = [NSArray arrayWithObjects:@"场地预定",@"约球",@"钻石搭档",@"中国", nil];
        
//        _fenLeiCount = _dataArray.count;
        [self craeatView];
    }
    return  self;
}
-(void)craeatView
{
    for (int i = 0; i < _fenLeiCount; i++) {
        [self fenLeiIcon:i name:[_dataArray objectAtIndex:i]];
    }
}
-(void)fenLeiIcon:(int)number name:(NSString*)name
{
    float EdgeInsets = (SCREEN_WIDTH-50*_fenLeiCount)/_fenLeiCount+1;
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(EdgeInsets/2+(number *(50+EdgeInsets)), 8, 50, 100)];
    [self addSubview:backView];
    
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    
    [image setBackgroundColor:[UIColor redColor]];
    [backView addSubview:image];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 50, 30)];
    [label setText:name];
    [label setFont:[UIFont systemFontOfSize:12]];
    [label setTextAlignment:NSTextAlignmentCenter];
    [backView addSubview:label];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
